      SUBROUTINE STVRBL(LTEST,DEP,SUBX,T)
C
C        STORES INITIAL CONDITIONS FOR STACKING CASES.
C        STVRBL IS CALLED FROM MAIN WITH LTEST = 1 IF SDPLY = 0 AT
C        START  OF RUN.  SDPLY IS SET 0 AT ENTRY MAIN
C        STVRBL IS CALLED FROM MAIN WITH LTEST = 2 IF TSTOP IS
C        PASSED AND IF MLAST NOT EQUAL TO 0 OR MDPLY = 0
C
CC       THIS ROUTINE IS INITIALLY WRITTEN BY E.A.LAWLOR OF
C        AVCO SYSTEM DIVISION, AND MODIFIED BY K. YONG OF COMPUTER
C        SCIENCES CORP. FOR ADDITIONAL CAPABILITIES
C
      IMPLICIT REAL*8(A-H,O-Z)
C
      COMMON/ANTENA/ A(10,3),ADOT(10,3),B(10,3),BDOT(10,3),DIN(10,3),
     .               DINDOT(10,3),DOUT(10,3),DOUTDT(10,3),ZBZ(3,10),
     .               NELMTS,NDAMPR,MODES(10)
C
      COMMON/CCNVRT/ BDYMI(3,3),DPRMI(3,3),EMODLS(10),RTUBE(10),
     .               HTUBE(10),THERMC(10),TIPMS(10),C(10)
C
      COMMON/CFNALP/ SCO,CIZO(3,3),CIYO(3,3),DONA(3,10),DONB(3,10)
     .              ,CDAMP(3,10)
C
      COMMON/CSTVAL/ TSTART,ZL0(10),ZL1(10),ZL2(10),ZLA(10)
C
      COMMON/CSOLAR/ SAO(10),SKA(9),SKB(9),SKOA(10,3),SKOB(10,3),
     .               STMK(10),SKAA(10,9),SKBB(10,9)
C
C
      COMMON/GRNTST/ALFAEG,DELTAG,PHASEG,ALTUDE,OMGY(3),
     *              GACC(3),GLOCAT(3),IGRUND,IALTUD,IGASBR
C
      COMMON/IMAIN1/ IDATE,LSAVE,INOPT,IPLOT,NUMEQS,IPLTPE,IORB,ITAPE
C
      COMMON/IPOOL1/ IGRAV,IADB ,IK,K1,ITIM,IAB,IAPS,IBB,IBPS,NK(10),
     .               LK(10),LLK(10)
C
      COMMON/LIBDPR/ ZK1D,ZK2D,PHIS,PHILD,DPHILD,BETLD,GAMLD,
     .               ZMDO,ZMDBO,CNV,DECAY
C
      COMMON/RPOOL1/ RHOK(10),TIME,SA(3,3),FM1(3,3),ZLK(10),OMEG(3),
     .               ZLKP(10),ZLKDP(10),CMAT(3,3),GBAR(3,3),YBCM(3),
     .               ZBZK(3,10),FCM(3,3),DTO,PHID,PHI
C
      COMMON/RTDIST/ TDIS(10)
C
      COMMON/SATLSH/ TAUK(10),OCULTK(10),RADSH
C
      COMMON/VECTRS/ XSAT(3),XSATDT(3),AD(3)
C
      COMMON/XKPLER/AS,E,F,EI,BW,W,BWDOT,WDOT
C
      DIMENSION STAUK(10),SOCULT(10)
      DIMENSION RHO(10),SAOK(10),ZLOK(10),ZL1K(10),ZLAK(10),EMDLS(10),
     .          SHTUBE(10),SRTUBE(10),STIPMS(10),STHRMC(10),SSTMK(10),
     .          ILK(10),ILLK(10),SCDAMP(3,10),SAVEC(10),IMODES(10),
     .          SZBZ(3,10),DEP(150),SUBX(3),XSAVE(3),DXSAV(3)
     .         ,SKOA1(10,3),SKOB1(10,3),TDIST(10)
C
      DIMENSION SGACC(3),SGLOCT(3)
C
C
C
      IF(LTEST.EQ.2) GO TO 20
C
      SAVET=T
      PHI=PHILD
      PHID=DPHILD
      SAGAM=GAMLD
      SDGAM=DGAMLD
      SAPHI=PHI
      SAPHID=PHID
      DO 10 I=1,10
      STAUK(I)=TAUK(I)
      SOCULT(I)=OCULTK(I)
      RHO(I)=RHOK(I)
      SAOK(I)=SAO(I)
      ZLOK(I)=ZL0(I)
      ZL1K(I)=ZL1(I)
      ZLAK(I)=ZLA(I)
      TDIST(I)=TDIS(I)
      EMDLS(I)=EMODLS(I)
      SHTUBE(I)=HTUBE(I)
      SRTUBE(I)=RTUBE(I)
      STIPMS(I)=TIPMS(I)
      STHRMC(I)=THERMC(I)
      SSTMK(I)=STMK(I)
      ILK(I)=LK(I)
      ILLK(I)=LLK(I)
      SAVEC(I)=C(I)
      IMODES(I)=MODES(I)
C
      DO 10 J=1,3
      SKOA1(I,J)=SKOA(I,J)
      SKOB1(I,J)=SKOB(I,J)
      SZBZ(J,I)=ZBZ(J,I)
   10 SCDAMP(J,I)=CDAMP(J,I)
C
      SAS=AS
      SE=E
      SEI=EI
      SBW=BW
      SW=W
      SF=F
      SBWDOT=BWDOT
      SWDOT=WDOT
      SALFAG=ALFAEG
      SDELTG=DELTAG
      DO 15 I=1,3
      SGACC(I)=GACC(I)
      SGLOCT(I)=GLOCAT(I)
      XSAVE(I)=XSAT(I)
   15 DXSAV(I)=XSATDT(I)
C
C
      CALL RELOC(DEP)
      CALL CONVRT
      CALL CKINPT(SUBX)
      IF(IGRUND.EQ.1) GO TO 323
      IF(INOPT.EQ.1) CALL SINPUT(DEP)
      IF(INOPT.EQ.2) CALL GINPUT(DEP)
      GO TO 324
 323  CONTINUE
      CALL GNDIPT(DEP)
 324  CONTINUE
      CALL STDPND(1)
C
C
      RETURN
C
C
   20 CALL STDPND(2)
C
C
      DO 30 I=1,10
      TAUK(I)=STAUK(I)
      OCULTK(I)=SOCULT(I)
      RHOK(I)=RHO(I)
      SAO(I)=SAOK(I)
      ZL0(I)=ZLOK(I)
      ZL1(I)=ZL1K(I)
      ZLA(I)=ZLAK(I)
      EMODLS(I)=EMDLS(I)
      HTUBE(I)=SHTUBE(I)
      RTUBE(I)=SRTUBE(I)
      TIPMS(I)=STIPMS(I)
      TDIS(I)=TDIST(I)
      THERMC(I)=STHRMC(I)
      STMK(I)=SSTMK(I)
      LK(I)=ILK(I)
      LLK(I)=ILLK(I)
      C(I)=SAVEC(I)
      MODES(I)=IMODES(I)
C
      DO 30 J=1,3
      SKOA(I,J)=SKOA1(I,J)
      SKOB(I,J)=SKOB1(I,J)
      ZBZ(J,I)=SZBZ(J,I)
   30 CDAMP(J,I)=SCDAMP(J,I)
C
      T=SAVET
      PHILD=SAPHI
      DPHILD=SAPHID
      ALFAEG=SALFAG
      DELTAG=SDELTG
C
C
      AS=SAS
      E=SE
      EI=SEI
      BW=SBW
      W=SW
      F=SF
      BWDOT=SBWDOT
      WDOT=SWDOT
      DO 40 I=1,3
      GACC(I)=SGACC(I)
      GLOCAT(I)=SGLOCT(I)
      XSAT(I)=XSAVE(I)
   40 XSATDT(I)=DXSAV(I)
C
      RETURN
      END
